﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.InterferenceVolume.CCoIVInterferenceVolumeCmd
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using EngineeringInternalExtension;
using System.Resources;
using System.Windows.Forms;
using Tecnomatix.Engineering;
using Tecnomatix.Engineering.Ui;


namespace DnProcessSimulateCommands.InterferenceVolume;

public class CCoIVInterferenceVolumeCmd : TxButtonCommand
{
  private CApIVInterferenceVolumeCmdEnabler m_enabler;
  private bool m_isFormOpened;

  public CCoIVInterferenceVolumeCmd() => this.m_enabler = new CApIVInterferenceVolumeCmdEnabler();

  public virtual void Execute(object cmdParams)
  {
    if (!TxCommandLicenser.InterferenceVolumeLicense)
    {
      TxMessageBoxEx.ShowNoLicenseError(base.Name);
    }
    else
    {
      if (this.m_isFormOpened)
        return;
      CUiIVInterferenceVolumeForm interferenceVolumeForm = new CUiIVInterferenceVolumeForm();
      ((Form) interferenceVolumeForm).FormClosed += new FormClosedEventHandler(this.ivForm_FormClosed);
      CUiIVInterferenceVolumeInitParams initParams = new CUiIVInterferenceVolumeInitParams();
      initParams.InitFromSelection();
      interferenceVolumeForm.Show(initParams);
      this.m_isFormOpened = true;
    }
  }

  public virtual bool Connect() => true;

  public virtual void Disconnect()
  {
  }

  public virtual string Category
  {
    get => this.GetResourceManager().GetString("CMD_INTERFERENCE_VOLUME_CATEGORY");
  }

  public virtual string Name => this.GetResourceManager().GetString("CMD_INTERFERENCE_VOLUME_NAME");

  public virtual string Bitmap => "InterferenceVolume.Res.CUiIVInterferenceVolumeCmdIcon.bmp";

  public virtual string LargeBitmap
  {
    get => "InterferenceVolume.Res.CUiIVInterferenceVolumeCmdIcon_LARGE.png";
  }

  public virtual string Description
  {
    get => this.GetResourceManager().GetString("CMD_INTERFERENCE_VOLUME_DESCRIPTION");
  }

  public virtual ITxCommandEnabler CommandEnabler => (ITxCommandEnabler) this.m_enabler;

  public virtual ITxImage Image => (ITxImage) TxImageManager.GetImageByKey("InterferenceVolume");

  private ResourceManager GetResourceManager()
  {
    return new ResourceManager("DnProcessSimulateCommands.InterferenceVolume.Res.CUiIVInterferenceVolumeResourceTable", ((object) this).GetType().Assembly);
  }

  private void ivForm_FormClosed(object sender, FormClosedEventArgs e)
  {
    this.m_isFormOpened = false;
    (sender as Form).FormClosed -= new FormClosedEventHandler(this.ivForm_FormClosed);
  }
}
